package org.zyx.goods.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.zyx.goods.service.GoodsHtmlService;
import org.zyx.goods.service.GoodsService;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author: SwordMaple
 * @Date: 2020/10/11  20:33
 * @Description:
 * @Version: 1.0
 */
@Controller
@RequestMapping
public class GoodsWebHandler {

    @Resource
    private GoodsService goodsService;
    @Resource
    private GoodsHtmlService goodsHtmlService;

    @GetMapping("/item/{id}.html")
    public String toItemPage(@PathVariable("id") Long spuId, Model model){

        Map<String, Object> map = goodsService.loadData(spuId);
        model.addAllAttributes(map);
        goodsHtmlService.asyncExcute(spuId);//页面静态化
        return "item";
    }




}
